package cn.bluethink.eguan.okrtask.mapper;

import java.util.List;

import org.apache.ibatis.annotations.Param;

import com.github.pagehelper.Page;

import cn.bluethink.eguan.okrtask.entity.EgOKRTaskEntity;
import cn.bluethink.eguan.okrtask.entity.OKRTaskEntity;
import tk.mybatis.mapper.common.Mapper;

public interface EgOKRTaskMapper extends Mapper<EgOKRTaskEntity> {

    public int updateOKRTask(@Param("entity") EgOKRTaskEntity entity) throws Exception;

    /**
     * 根据查询条件联合查询工作任务信息列表
     * 
     * @param whereSql
     * @return
     * @throws Exception
     */
    public Page<OKRTaskEntity> selectTasksByCondition(@Param("whereSql") String whereSql,
            @Param("orderSql") String orderSql) throws Exception;

    /**
     * 根据当前登录用户和要查看的用户获取在当前门派（fid）中两者共存的驿馆Id列表
     * 
     * @param currentuid
     * @param uid
     * @return
     * @throws Exception
     */
    public List<Long> getEgids(@Param("currentuid") Long currentuid, @Param("uid") Long uid, @Param("fid") Long fid)
            throws Exception;

    public Integer countByStatus(@Param("countsql") String countsql) throws Exception;

    public int updateSort(@Param("sortSql") String sortSql, @Param("bUp") boolean bUp) throws Exception;

    public int updateSortByTid(@Param("tid") Long tid, @Param("sort") Integer sort) throws Exception;


    /**
     * 根据驿馆ID、目标标识、目标的起止时间获取目标列表
     * 
     * @param egid
     * @param timing
     * @param btime
     * @param etime
     * @return
     * @throws Exception
     */
    List<OKRTaskEntity> getParents(@Param("egid") Long egid, @Param("timing") Integer timing,
            @Param("btime") String btime, @Param("etime") String etime) throws Exception;

    /**
     * 批量更新工作任务(将关联的目标设置为null)
     * 
     * @param taskList
     * @return
     * @throws Exception
     */
    Integer updateOkrTaskList(@Param("taskList") List<EgOKRTaskEntity> taskList) throws Exception;

    /**
     * 定时删除工作任务
     * 
     * @throws Exception
     */
    public int del() throws Exception;

    /**
     * 定时删除关键项
     * 
     * @throws Exception
     */
    public int delKrs() throws Exception;

}
